/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.ac.c0910g.assignment.DAO;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import vn.ac.c0910g.assignment.Entity.ContactUS;
import vn.ac.c0910g.assignment.Entity.ContactUSFacade;

/**
 *
 * @author BachLe
 */
public class ContactUSDAO {
    ContactUSFacade contactUSFacade = lookupContactUSFacadeBean();

    public ContactUSDAO(){
        
    }
    private ContactUSFacade lookupContactUSFacadeBean() {
        try {
            Context c = new InitialContext();
            return (ContactUSFacade) c.lookup("java:global/Alluring_Decors/Alluring_Decors-ejb/ContactUSFacade!vn.ac.c0910g.assignment.Entity.ContactUSFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<ContactUS> getAllContactUS(){
        return this.contactUSFacade.findAll();
    }

    public void addContactUS(ContactUS contact){
        contactUSFacade.create(contact);
    }

    public void updateContactUS(ContactUS contact){
        contactUSFacade.edit(contact);
    }

    public void deleteContactUS(ContactUS contact){
        contactUSFacade.remove(contact);
    }

    public ContactUS findContactById(String Id){
        return contactUSFacade.find(Id);
    }
}
